home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / C / Comet2.1.3.cpt / 3270XCMD / TNQuit.c < prev    next >
Text File  |  1990-03-21  |  1KB  |  74 lines

  1. /* TNQuit.c -- XCMD to close the TN3270 driver 
  2.     copyright 1989 Cornell University 
  3. */
  4.  
  5.  
  6. #include <Types.h>
  7. #include <Memory.h>
  8. #include <Devices.h>
  9. #include <HyperXCmd.h>
  10. #include <Errors.h>
  11.  
  12. #include "TNdrvr.h"
  13.  
  14.  
  15. pascal void debugger()    extern 0xA9FF;   
  16.  
  17.  
  18. pascal void TNQuit(hycp)
  19. XCmdPtr hycp;
  20. {
  21.     CntrlParam drvpb;
  22.     long * args;
  23.     Str255 pstr;
  24.     
  25.     if (hycp->paramCount != 1) {
  26.         sethand(&hycp->returnValue, "TNQuit TNID: need 1 argument");
  27.         return;
  28.     }
  29.     
  30.     HLock((Handle) hycp->params[0]);
  31.     
  32.     ZeroToPas(hycp, *hycp->params[0], (StringPtr) &pstr[0]);
  33.     drvpb.ioCRefNum = (short) StrToNum(hycp, (Str31 *) &pstr[0]);
  34.     drvpb.csCode = HTN_QUIT;
  35.     PBControl((ParmBlkPtr) &drvpb, (Boolean) 0);
  36.  
  37.     if (drvpb.ioResult) {
  38.         /* close call failed */
  39.         switch (drvpb.ioResult) {
  40.             case HTNR_NOTN: {
  41.                 sethand(&hycp->returnValue, "TN is not running");
  42.                 break;
  43.             }
  44.             case badUnitErr: {
  45.                 sethand(&hycp->returnValue, "TNID is incorrect");
  46.                 break;
  47.             }
  48.             default: {
  49.                 sethand(&hycp->returnValue, "Unknown error");
  50.                 break;
  51.             }
  52.         }
  53.     }
  54.     HUnlock((Handle) hycp->params[0]);
  55.     return;
  56. }
  57.  
  58.  
  59. sethand(thand, str)
  60. Handle * thand;
  61. char * str;
  62. {
  63.     if (*thand == NULL) {
  64.         *thand = NewHandle((Size) 0);
  65.     }
  66.     SetHandleSize(*thand, (long) (strlen(str) + 1));
  67.     strcpy(**thand, str);
  68. }
  69.  
  70.  
  71.  
  72.  
  73. #include <XCmdGlue.inc.c>
  74.